package com.example.beautymakeup.controller;

import com.example.beautymakeup.domain.Result;
import com.example.beautymakeup.pojo.Admin;
import com.example.beautymakeup.service.LoginService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


@RestController
@RequestMapping("/login")
public class LoginController {
    @Autowired
    private LoginService loginService;

    @GetMapping
    public Result login(@RequestParam("code") String code) {
        return loginService.login(code);
    }

    @GetMapping("/admin")
    public Result admin(Admin admin){
        System.out.println("账号密码");
        System.out.println(admin.getUsername());
        System.out.println(admin.getPassword());
        return loginService.admin(admin);
    }

    @PostMapping("/logout")
    public Result logout(@RequestHeader("Shop_token") String token) throws Exception {
        return loginService.logout(token);
    }
}
